﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbstractFactory
{
    /*表数据结构*/
    class User
    {
        public int ID
        {
            get;
            set;
        }
        
        public string Name
        {
            get;
            set;
        }
    }

    /*数据库操作接口*/
    interface IUser
    {
        void Insert(User user);
        User GetUser(int id);
    }

    /*SqlServer 操作接口*/
    class SqlserverUser : IUser
    {
        public User GetUser(int id)
        {
            Console.WriteLine("Sql Server 中给 获取一条User数据!");
            return new User() { ID = id, Name = "name" + id };
        }

        public void Insert(User user)
        {
            Console.WriteLine("Sql Server 中给 User表增加一条记录!");
        }
    }

    /*Access操作接口*/
    class AccessUser : IUser
    {
        public User GetUser(int id)
        {
            Console.WriteLine(" Access 中给 获取一条User数据!");
            return new User() { ID = id, Name = "name" + id };
        }

        public void Insert(User user)
        {
            Console.WriteLine("Access 中给 User表增加一条记录!");
        }
    }
}
